<%-- 
    Document   : statistics
    Created on : 13-mar-2012, 16:03:22
    Author     : Alvaro
--%>

<%@page import="com.sun.org.apache.xerces.internal.impl.dv.xs.DayDV"%>
<%@page import="java.util.ArrayList"%>
<%@page import="classes.order"%>
<%@page import="classes.AdminDB"%>
<%@page import="classes.graph"%>
<%ArrayList<order> orders = (ArrayList<order>) session.getAttribute("statsDay");%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Statistics | Admin</title>
        <script type="text/javascript" src="../js/jscharts.js"></script>
        <link rel="stylesheet" type="text/css" href="../css/admin.css" />
        
        
        <link type="text/css" href="../css/ui-lightness/jquery-ui-1.8.18.custom.css" rel="stylesheet" />	
		<script type="text/javascript" src="../js/jquery-1.7.1B.min.js"></script>
		<script type="text/javascript" src="../js/jquery-ui-1.8.18.custom.min.js"></script>
		<script type="text/javascript">
			$(function(){

				// Datepicker
				$('#datepicker').datepicker({
					inline: true
				});
				
				//hover states on the static widgets
				$('#dialog_link, ul#icons li').hover(
					function() { $(this).addClass('ui-state-hover'); }, 
					function() { $(this).removeClass('ui-state-hover'); }
				);
				
			});
		</script>
    </head>
    <body>
        <h1 align="center" class="tituloStatsEstrecho">Stats</h1>
        <h2 align="center" class="tituloStatsEstrecho">By day</h2>
        <div align="center">
          <table width="60%" border="0">
            <tr>
              <th scope="col">&nbsp;</th>
            </tr>
            <tr>
              <td><form name="FormDateAux" method="post" action="statsDay.jsp">
                <input name="date" id="datepicker" type="date" name="fechaHoraCita" placeholder="Fecha y Hora" required/>
                <input type="submit" value="accept">
                or<br/>
              </form></td>
            </tr>
            <tr>
              <td><form name="FormDate" method="post" action="statsDay.jsp">
                <label for="day">Day</label>
                <select name="day" id="day">
                  <option value="%">-</option>
                  <option value="Mon">Mon</option>
                  <option value="Tue">Tue</option>
                  <option value="Wed">Wed</option>
                  <option value="Thu">Thu</option>
                  <option value="Fri">Fri</option>
                  <option value="Sat">Sat</option>
                  <option value="San">San</option>
                </select>
                <label for="number">Day (number)</label>
                <select name="number" id="number">
                  <option value="%">-</option>
                  <option value="1">1</option>
                  <option value="2">2</option>
                  <option value="3">3</option>
                  <option value="4">4</option>
                  <option value="5">5</option>
                  <option value="6">6</option>
                  <option value="7">7</option>
                  <option value="8">8</option>
                  <option value="9">9</option>
                  <option value="10">10</option>
                  <option value="11">11</option>
                  <option value="12">12</option>
                  <option value="13">13</option>
                  <option value="14">14</option>
                  <option value="15">15</option>
                  <option value="16">16</option>
                  <option value="17">17</option>
                  <option value="18">18</option>
                  <option value="19">19</option>
                  <option value="20">20</option>
                  <option value="21">21</option>
                  <option value="22">22</option>
                  <option value="23">23</option>
                  <option value="24">24</option>
                  <option value="25">25</option>
                  <option value="26">26</option>
                  <option value="27">27</option>
                  <option value="28">28</option>
                  <option value="29">29</option>
                  <option value="30">30</option>
                  <option value="31">31</option>
                </select>
                <label for="month">Month</label>
                <select name="month" id="month">
                  <option value="%">-</option>
                  <option value="Jan">Jan</option>
                  <option value="Feb">Feb</option>
                  <option value="Mar">Mar</option>
                  <option value="Apr">Apr</option>
                  <option value="May">May</option>
                  <option value="Jun">Jun</option>
                  <option value="Jul">Jul</option>
                  <option value="Aug">Aug</option>
                  <option value="Sep">Sep</option>
                  <option value="Oct">Oct</option>
                  <option value="Nov">Nov</option>
                  <option value="Dec">Dec</option>
                </select>
                <label for="year">Year</label>
                <select name="year" id="year">
                  <option value="%">-</option>
                  <option value="2009">2009</option>
                  <option value="2010">2010</option>
                  <option value="2011">2011</option>
                  <option value="2012">2012</option>
                </select>
                <input type="submit" value="accept">
              </form></td>
            </tr>
            </table>
        </div>
        <p align="center">&nbsp;</p>
    <p>
        <script>
            var myData = new Array();
        </script>
        </p>
    <p>
    <%
          
            String day="";
            String number="";
            String month="";
            String year="";
            String date="";
            
            
            day = request.getParameter("day");
            number = request.getParameter("number");
            month = request.getParameter("month");
            year = request.getParameter("year");
            
          
            date = day+" "+number+" "+month+" "+year;
            
            int i = 0,p=0;
            int[] arrayX = new int[100];


            String sentencia = "";

            graph g = new graph();
            AdminDB adb = new AdminDB();

                if (orders == null) {%>
        </p>
        <form name="form1" method="post" action="/ShopOnline/listOrders">
        <input type="submit" name="cargasProd" id="cargasProd" value="Load">
            <input type="hidden" name="orderinfo" value="stats">
        </form>	
        <%} else {
            //while (i < 28) {
                arrayX[i] = i;
                p = g.getPointsDayY(adb.getConnection(),day,number,month,year);
                
                
                sentencia += "(['" + arrayX[i] + "'," + p + "])";
                
                i = i + 1;
                System.out.println("Grafica days/values= " + sentencia);
                //sentencia += "(['"+arrayX[i]+","+arrayY[i]+"])";
                //}
                %>




        <div id="graph">Loading graph...</div>

        <p>
<%
                }%>
        </p>
            <h2 align="center">More stats    </h2>
    <div align="center">
              <table width="15%" border="0" class="titulo">
                <tr>
                  <th scope="col"><p align="center"><a href="statsBestsellers.jsp">Bestsellers</a></p>
                    <p align="center"><a href="statsStock.jsp">Stock</a></p>
                    <p align="center"><a href="statsDay.jsp">Sales</a></p>
                    <p align="center"><a href="statsBestCustomers.jsp">Customers</a></p></th>
                </tr>
              </table>
            </div>
            <p align="center"><a href="statistics.jsp">back</a></p>
<h2 align="center"><a href="Admin.jsp"><img src="../images/b_prev.png" alt="back" width="40" height="40" align="absmiddle">Admin</a></h2>
<script type="text/javascript">
                myData = Array(<%=sentencia%>);
                //Array: primer valor: x | segundo valor: y(veces comprado)
                var colors = ['#AF0202'];
                var myChart = new JSChart('graph', 'bar');
                myChart.setDataArray(myData);
                myChart.setTitle('Date: <%=date%>');
                myChart.setTitleColor('#8E8E8E');
                myChart.setTitleFontSize(11);
                myChart.setAxisNameX('');
                myChart.setAxisNameY('');
                myChart.setAxisColor('#C4C4C4');
                myChart.setAxisValuesColor('#343434');
                myChart.setAxisPaddingLeft(80);
                myChart.setAxisPaddingRight(10);
                myChart.setAxisPaddingTop(50);
                myChart.setAxisPaddingBottom(40);
                myChart.setAxisValuesNumberX(6);
                myChart.setGraphExtend(true);
                myChart.setGridColor('#c2c2c2');
                myChart.setLineWidth(6);
                myChart.setLineColor('#9F0505');
                myChart.setSize(520, 321);
                myChart.setBackgroundImage('chart_bg.jpg');
                myChart.draw();
        </script>
        
        
<!-- end scripts-->
    </body>
</html>
